package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFIll;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface SetmealMapper {

    @Select("select count(*) from setmeal where category_id = #{type}")
    Integer countByCategoryId(Integer type);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @AutoFIll(OperationType.INSERT)
    @Insert("insert into setmeal values (null, #{categoryId}, #{name}, #{price}, #{status}, #{description}, #{image}, " +
            "#{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insert(Dish dish);

    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    @AutoFIll(OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Select("select * from setmeal where id = #{setmealId}")
    Setmeal selectById(Long setmealId);

    void deleteBatch(List<Long> setmealIds);

    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> selectByCategoryId(Integer categoryId);
}
